package com.transmit.core;

import com.alibaba.fastjson.JSON;

/**
 * 统一API响应结果封装
 */
public class Result {
    //结果判断
    public static final String successEng = "success";
    public static final String failureEng = "failure";

    //操作结果
    public static final String success = "成功";
    public static final String failure = "失败";
    //类型
    public static final String register = "注册";
    public static final String insert = "添加";
    public static final String update = "修改";
    public static final String select = "查询";
    public static final String delete = "删除";
    public static final String input = "导入";
    public static final String output = "导出";
    public static final String cancel = "取消";
    public static final String login = "登录";
    public static final String logout = "登出";
    public static final String upload = "上传";
    public static final String verify = "验证";
    public static final String send = "发送";
    public static final String forget = "忘记密码";

    private int code;
    private String message;
    private Object data;

    public Result setCode(ResultCode resultCode) {
        this.code = resultCode.code;
        return this;
    }

    public int getCode() {
        return code;
    }

    public Result setCode(int code) {
        this.code = code;
        return this;
    }

    public String getMessage() {
        return message;
    }

    public Result setMessage(String message) {
        this.message = message;
        return this;
    }

    public Object getData() {
        return data;
    }

    public Result setData(Object data) {
        this.data = data;
        return this;
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }
}
